# $Id$
# Maintainer:  Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Andrzej Giniewicz <gginiu@gmail.com>
# Contributor: Johan Förberg <johan@forberg.se>

pkgname=zstd
pkgver=1.3.5
pkgrel=1
pkgdesc='Zstandard - Fast real-time compression algorithm'
arch=(x86_64)
url='http://www.zstd.net/'
license=(BSD GPL2)
depends=(zlib xz lz4)
makedepends=(gtest)
source=(zstd-$pkgver.tar.gz::https://github.com/facebook/zstd/archive/v${pkgver}.tar.gz
        zstd-1.3.5-fix-tests.patch)
sha256sums=('d6e1559e4cdb7c4226767d4ddc990bff5f9aab77085ff0d0490c828b025e2eea'
            '3c34c2aed193595559c1b3cb4503d81c73d3e21dcf8ab659b26aa917abcb194c')

prepare() {
  cd $pkgname-$pkgver
  patch -p1 -i "$srcdir/zstd-1.3.5-fix-tests.patch"
}

build() {
  cd $pkgname-$pkgver
  make
  make zstdmt
  make -C contrib/pzstd
}

check() {
  cd $pkgname-$pkgver
  make check    
  make -C contrib/pzstd test
}

package() {
  cd $pkgname-$pkgver
  make PREFIX=/usr DESTDIR="$pkgdir/" install
  install -Dm755 zstdmt "$pkgdir/usr/bin/zstdmt"
  install -Dm755 contrib/pzstd/pzstd "$pkgdir/usr/bin/pzstd"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
